# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=libdispatch
pkgver=5.6.2
pkgrel=0
pkgdesc="Comprehensive support for concurrent code execution on multicore hardware"
url="https://apple.github.io/swift-corelibs-libdispatch"
# armhf: fatal error: error in backend: Cannot select: intrinsic %llvm.arm.clrex
# riscv64: failing tests
arch="all !armhf !riscv64"
license="Apache-2.0"
depends_dev="$pkgname bsd-compat-headers"
makedepends="$depends_dev clang cmake samurai linux-headers"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/apple/swift-corelibs-libdispatch/archive/swift-$pkgver-RELEASE/libdispatch-$pkgver.tar.gz
	avoid-libkqueue.patch
	remove-werror.patch
	getprogname-musl.patch
	"
builddir="$srcdir/swift-corelibs-libdispatch-swift-$pkgver-RELEASE"

build() {
	export CFLAGS="$CFLAGS -D_GNU_SOURCE"
	export CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE"
	export CC=clang
	export CXX=clang++

	cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel
	cmake --build build
}

check() {
	ctest --output-on-failure -j $JOBS --test-dir build \
		-E dispatch_select # timeout
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
bd1a7c6eefadb1009448b937ddf3a388e3608bf1a2dff282c8eb5714679e2f17c4dd389b5a28c2898a32fd3609f3fdbf675ef04bc84fe63bffee0ca867f192ed  libdispatch-5.6.2.tar.gz
f446969a2ccd6368b8ae994712019271438b050659e6a600f1d542516981ff9879d65ba48c5c0c2664ed9961aa61edb6c8f5febe447bdeb0ad71b0d9fcd426df  avoid-libkqueue.patch
28d74bee58c1db1ed6d865dfea7e6aca18435b5ccfa77bd172fed17bda93b8ed997b614c40b728e3412a3a61531f01ce1f2ce636dc08a21d1606a7099da7a90f  remove-werror.patch
148da81026badd7999c2317dfcfe274e544562a5ef294253738add68d203e450d430a16f43eb6674c3b3b3f18a6b82799bce3f5aebcbe3f80ee460dbb38e4663  getprogname-musl.patch
"
